<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.6/iconfont.css" rel="stylesheet"
	type="text/css" />
<link rel="stylesheet"
	href="lib/webuploader/webuploader.css" />
<link href="lib/webuploader/0.1.5/webuploader.css" rel="stylesheet"/>
<link href="css/colorpicker.css" rel="stylesheet"/>
<link href="css/layout.css" rel="stylesheet"/>
<link href="css/common.css" rel="stylesheet" type="text/css" />

<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<style>
.file-bottom {
	position: relative;
}

.file-form {
	position: absolute;
	top: 0;
}
</style>
<title>新增专场</title>
</head>
<body>
	<div class="pd-20">
	<%--  --%>
		 <form action="" method="post"
			class="form form-horizontal" id="form-sc-add"> 
			
			<div class="row cl">
						<label class="form-label col-2">企业主：</label>
				<div class="formControls col-2">
					<span class="select-box"><select name="ent_id" id="entId"
						class="select" datatype="*" nullmsg="请选择类型">
						<option value="-1">--请选择--</option>
							<c:forEach items="${entrepreneurs}" var="entrepreneur">
								<option value="${entrepreneur.user_id}"<c:if test="${entrepreneur.user_id==memberId}">selected</c:if>>${entrepreneur.corp_fname}</option>
							</c:forEach>
					</select></span>
				</div>
			</div>
			
			<div class="row cl">
						<label class="form-label col-2">专场类别：</label>
						<div class="formControls col-2" style="text-align:left;">
							<span class="select-box"> <select class="select"
								name="typeId" id="typeId">
									<option value="-1">--请选择--</option>
									<c:forEach items="${types}" var="type">
										<option value="${type.C_CODE}"<c:if test="${type.C_CODE==topicMap.type_id}">selected</c:if>>${type.C_NAME}</option>
									</c:forEach>
							</select>
							</span>
						</div>
			</div>
			
			<div class="row cl">
				<label class="form-label col-2"><span class="c-red">*</span>专场时间：</label>
				<div class="formControls col-2">
					<input id="start_date" name="start_date" value="${topicMap.start_date }" onclick="new WdatePicker()" class="Wdate">
				</div>
				<div class="formControls col-2">
				<select name="hour" id="hour"
						class="select">
							<option value="-1">--时间--</option>
							<c:forEach items="${timeMap}" var="type">
										<option value="${type.key}"<c:if test="${type.key==time}">selected</c:if>>${type.value}</option>
									</c:forEach>
					</select>
					</div>
			</div>
			<div class="row cl">
				<label class="form-label col-2"><span class="c-red">*</span>专场名称：</label>
				<div class="formControls col-2">
					<input id="title" name=title value="${topicMap.title}">
				</div>
				
			</div>
			
			<div class="row cl">
				<label class="form-label col-2"><span class="c-red">*</span>专场图片：</label>
				<div class="formControls col-2">
				<div id="iconimgdiv" class="uploader-thum-container">
								<img 
								<c:if test="${topicMap.topic_img!=''&&!empty topicMap.topic_img}">src="<%=imagePath%>${topicMap.topic_img}"</c:if>
								alt="" class="margin" id="iconImg" style="height: 100px;">
							<a id="iconbutton" class="btn btn-primary"><i
								class="glyphicon glyphicon-picture"></i> 上传图片</a>
						</div>
				</div>
				
			</div>
			</form> 
					<input type="hidden" name="topicImg" id="topicImg" value="${topicMap.topic_img}" />
					<input type="hidden" name="topicId" id="topicId" value="${topicMap.topic_id}" />
		

			<c:if test="${not empty flag }">
			<table
				class="table table-border table-bordered table-hover table-bg table-sort">
				<thead>
					<tr class="text-c">
					<th width="80">id</th>
						<th width="80">商品名称</th>
						<th>市场价</th>
						<th>销售价</th>
						<th>库存</th>
						<th>图片</th>
						<th width="120">操作</th>
					</tr>
				</thead>
					<tbody id="tb">
					<c:choose>
						<c:when test="${empty goodList}">
							<tr class="text-c">
								<td colspan="7">暂无数据</td>
							</tr>
						</c:when>
						<c:otherwise>
							<c:forEach items="${goodList}" var="var">
								<tr class="text-c">
								    <td>${var.ID }<input type="hidden" id="topicLinkId" name="topicLinkId" value='${var.TOPIC_LINK_ID}' /></td>
									<td>${var.NAME}</td> 
									<td>${var.MKT_PRICE}</td> 	
									<td>${var.PRICE}</td> 	
									<td>${var.STORE}</td> 	
									<td><img src="<%=imagePath%>${var.IMAGE}"  style="height:30px"/></td>
									<td class="td-manage">
										<a onClick="t_good_delete(this,'${var.topicLinkId}')" href="javascript:void(0);" title="删除">删除</a></td>
								</tr>
							</c:forEach>
						</c:otherwise>
					</c:choose>

				</tbody>
			</table>
			</c:if>
		
			
			<button onClick="sp_upd_submit();" id="save-btn"
				class="btn btn-primary radius" type="" style="">
				<i class="Hui-iconfont">&#xe632;</i> 发布
			</button>

		
		</div>

		<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
		<script type="text/javascript" src="lib/layer/2.1/layer.js"></script>
		<script type="text/javascript" src="lib/My97DatePicker/WdatePicker.js"></script>
		<script type="text/javascript" src="lib/icheck/jquery.icheck.min.js"></script>
		<script type="text/javascript"
			src="lib/Validform/5.3.2/Validform.min.js"></script>
		<script type="text/javascript"
			src="lib/webuploader/0.1.5/webuploader.min.js"></script>
		<script type="text/javascript"
			src="lib/ueditor/1.4.3/ueditor.config.js"></script>
		<script type="text/javascript"
			src="lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
		<script type="text/javascript" src="js/H-ui.js"></script>
		<script type="text/javascript" src="js/H-ui.admin.js"></script>
		<script type="text/javascript" src="js/jquery.form.js"></script>
		<script type="text/javascript" src="js/colorpicker.js"></script>
		<script type="text/javascript" src="js/eye.js"></script>
    	<script type="text/javascript" src="js/utils.js"></script>
    	<script type="text/javascript" src="js/layout.js?ver=1.0.2"></script>
    	<script type="text/javascript" src="<%=basePath%>plugins/plupload/plupload.full.min.js"></script>
	    <script type="text/javascript" src="<%=basePath%>js/jQuery-2.1.4.min.js"></script>
	    <script type="text/javascript" src="<%=basePath%>js/My97DatePicker/WdatePicker.js"></script>
         <script type="text/javascript">
         
         	var iconuploader = new plupload.Uploader({
			runtimes : 'html5,flash,silverlight,html4',
			browse_button : 'iconbutton', // you can pass in id...
			container : document.getElementById('iconimgdiv'), // ... or DOM Element itself
			url : '<%=path%>/backstage/goodstags-smallpic-upload',
			flash_swf_url : 'plupload/Moxie.swf',
			multi_selection : false,
			filters : {
				max_file_size : '5mb',
				mime_types : [ {
				title : "Image files",
					extensions : "jpg,gif,png"
				}, ]
			},
			init : {
				//文件上传成功回调
				FileUploaded : function(up, file, res) {
					var info = eval('(' + res.response + ')');
					if (info.error == "0000") {
						$("#iconImg").attr("src","<%=imagePath%>"+info.datas);
						$("#topicImg").val(info.datas);
					} else {
						layer.msg(info.information, {
							icon : 2
						});
					}
				},
				//添加文件回调
				FilesAdded : function(up, files) {
					$.each(up.files, function(i, file) {
						if (up.files.length <= 1) {
							return;
						}
						up.removeFile(file);
					});

					iconuploader.start();
				},
				//文件上传进度回调
				UploadProgress : function(up, file) {
					//$("#jindu").html(file.percent + "%");
					//alert(file.percent);
					//$("#proId").css("width",file.percent+"%");
				},
				//上传出错
				Error : function(up, err) {
					var msg = "";

					if (err.code == -601) {
						msg = "文件类型错误";
					} else if (err.code == -600) {
						msg = "文件过大";
					} else {
						/* alert(err.code); */
						msg = "文件异常";
					}
					layer.msg(msg, {
						icon : 2
					});
				}
			}
		});
		iconuploader.init();
		
		
	/* 	/* /*删除*/
		function t_good_delete(obj,id){
			layer.confirm('确认删除？', {
				btn: ['确认','取消'], 
				shade: false
			},
			function(){
				$.ajax({
					type : "POST",
					url : "<%=path%>/backstage/topic-goods-delete",
					data : {topicLinkId:$("#topicLinkId").val()},
					error : function() {
						layer.msg('操作失败', {
							icon : 5,
							time : 1000
						});
					},
					success : function(msg) {
						layer.msg('已删除 ' + msg.information, {
							icon : 6,
							time : 1000
						});
						  location.reload();
					}
				});
			}, function() {
				layer.msg('未删除', {
					icon : 5,
					time : 1000
				});
			});
		} 
	
	function sp_upd_submit(){
		 var cols="";   
		 $("#tb tr").each(function(){     
			 var text = $(this).children("td:first").text();      
			 cols+=text+",";   
		 });
			 cols=cols.length>0?cols.substring(0,cols.length-1):"";    
			 
			 var typeId=$("#typeId").val();
			 var hour=$("#hour").val();
			 var title=$("#title").val();
			 var topicImg=$("#topicImg").val();
			 var start_date=$("#start_date").val();
			 var topicId=$("#topicId").val();
			 var entId=$("#entId").val();
			 
			 $.ajax({
					type:"post",
					async:false,
					url:"<%=path%>/backstage/addSpeicalChang",
					data : {typeId:typeId,hour:hour,title:title,topicImg:topicImg,start_date:start_date,topicId:topicId,goodsStr:cols,entId:entId},
					success : function(msg){
						layer.msg('操作成功 ' + msg.information, {
							icon : 6,
							time : 1000
						});
							//location.href ="<%=path%>/backstage/addSpeicalChang";
							location.reload();
					}
					});
				}
 </script>

</body>
</html>